package cn.etcweb.bait.baitframe.auth.integration.authenticator.password;

import cn.etcweb.bait.baitframe.auth.bean.SysUser;
import cn.etcweb.bait.baitframe.auth.integration.IntegrationAuthentication;
import cn.etcweb.bait.baitframe.auth.integration.authenticator.AbstractPreparableIntegrationAuthenticator;
import com.xiaoleilu.hutool.util.StrUtil;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

/**
 * 默认登录处理
 */
@Component
@Primary
public class UsernamePasswordAuthenticator extends AbstractPreparableIntegrationAuthenticator {
    @Override
    public SysUser authenticate(IntegrationAuthentication integrationAuthentication) {
        //获取当前登录用户信息
        String username=integrationAuthentication.getUsername();
        SysUser user=new SysUser();
        user.setUsername(username);
        user.setPassword("123456");
        user.setStatus("1");
        return user;
    }

    @Override
    public void prepare(IntegrationAuthentication integrationAuthentication) {

    }

    @Override
    public boolean support(IntegrationAuthentication integrationAuthentication) {
        return StrUtil.isEmpty(integrationAuthentication.getAuthType());
    }
}
